package com.stellar.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @author Jqcc
 * @version 1.0
 * @date 2025/2/13
 * 异步任务配置 - 当前仅用于邮件发送
 */
@Configuration
@EnableAsync
public class AsyncConfig {

    /**
     * 邮件发送线程池
     *
     * @return
     */
    @Bean("mailTaskExecutor")
    public Executor emailExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(5);
        executor.setQueueCapacity(100);
        executor.setThreadNamePrefix("email-sender-");
        executor.initialize();
        return executor;
    }
}